package com.fg.cloud.manager.service.factory.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fg.cloud.common.PageUtils;
import com.fg.cloud.manager.entry.BaseEntity;
import com.fg.cloud.manager.entry.factory.LogisticsEntity;
import com.fg.cloud.manager.mapper.BaseMapper;
import com.fg.cloud.manager.mapper.factory.LogisticsMapper;
import com.fg.cloud.manager.service.BaseServiceImpl;
import com.fg.cloud.manager.service.factory.LogisticsService;

/**
 * Description:物流公司信息接口实现
 * 
 * @author shaoqiping
 * @date 2017年8月7日上午10:15:58
 */
@Service
public class LogisticsServiceImpl extends BaseServiceImpl implements LogisticsService {

	@Autowired
	private LogisticsMapper logisticsMapper;

	@Override
	protected <T extends BaseEntity> BaseMapper getBaseMapper() {
		return logisticsMapper;
	}

	@Override
	public void findList(PageUtils<LogisticsEntity> pageinfo) {
		long total = logisticsMapper.filterCount(pageinfo.getCondition());
		pageinfo.setTotal(total);
		if (total > 0) {
			pageinfo.setData(logisticsMapper.findList(pageinfo));
		} else {
			pageinfo.setData(new ArrayList<LogisticsEntity>());
		}

	}

	@Override
	public LogisticsEntity findByLogisticsName(LogisticsEntity logisticsEntity) {
		return logisticsMapper.selectByLogisticsName(logisticsEntity);
	}

	@Override
	@Transactional
	public boolean deletes(Map<String,Object> map) {
		String[] idArray = ((String) map.get("ids")).split("[, ]+");
		map.put("ids", idArray);
		int temp = logisticsMapper.deletes(map);
		return temp > 0 ? true : false;
	}

	@Override
	public List<LogisticsEntity> findAll(Long facId) {
		return logisticsMapper.selectAll(facId);
	}

}
